<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //reverse 数组的翻转
      var arr1 = [1, 2, 3, 4, 5, 6];
      console.log(arr1.reverse());//[6, 5, 4, 3, 2, 1]

      //sort 冒泡排序
      var arr2 = [12, 89, 25, 47, 5, 3];
      //升序
      var arr3 = arr2.sort(function (a, b) {
        return a - b;
      });
      console.log(arr3); //[3, 5, 12, 25, 47, 89]

      //降序
      var arr4 = arr2.sort(function (a, b) {
        return b - a;
      });
      console.log(arr4); //[89, 47, 25, 12, 5, 3]
    </script>
  </body>
</html>
